<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="销售退款单编号" prop="refundNo">
        <el-input
          v-model="queryParams.refundNo"
          placeholder="请输入销售退款单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="退货单" prop="returnNo">
        <el-input
          v-model="queryParams.returnNo"
          placeholder="请输入退货单"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="退款日期" prop="refundDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.refundDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择退款日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="账户" prop="account">
        <el-input
          v-model="queryParams.account"
          placeholder="请输入账户"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否开票" prop="isInvoice">
        <el-input
          v-model="queryParams.isInvoice"
          placeholder="请输入是否开票"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="付款方式" prop="payType">
        <el-select v-model="queryParams.payType" placeholder="请选择付款方式" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="销售负责人" prop="follower">
        <el-input
          v-model="queryParams.follower"
          placeholder="请输入销售负责人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['crm:refund:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['crm:refund:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['crm:refund:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['crm:refund:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="refundList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="销售退款单编号" align="center" class-name="small-padding fixed-width" prop="refundNo">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        @click="getRefundInfo(scope.row)"
                        v-hasPermi="['system:contract:list']"
                      >{{scope.row.refundNo}}</el-button>
                    </template>
            </el-table-column>
            <el-table-column label="客户名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        @click="getCustomerInfo1(scope.row)"
                        v-hasPermi="['system:contract:list']"
                      >{{scope.row.customerName}}</el-button>
                    </template>
            </el-table-column>
            <el-table-column label="销售退货单编号" align="center" class-name="small-padding fixed-width" prop="returnNo">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        @click="getInfoByReturnNo1(scope.row)"
                        v-hasPermi="['system:contract:list']"
                      >{{scope.row.returnNo}}</el-button>
                    </template>
            </el-table-column>
      <el-table-column label="退款日期" align="center" prop="refundDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.refundDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="账户" align="center" prop="account" />
      <el-table-column label="是否开票" align="center" prop="isInvoice" />
      <el-table-column label="付款方式" align="center" prop="payType" />
      <el-table-column label="销售负责人" align="center" prop="follower" />
      <el-table-column label="修改时间" align="center" prop="updateTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['crm:refund:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['crm:refund:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

<el-dialog :title="title" :visible.sync="dialogVisible" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="客户详情" name="first">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="基本信息" name="1">
           <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
              <el-descriptions-item >
                <template slot="label">
                      客户名称
                </template>
                {{CustomerInfo.customerName}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      上级单位
                </template>
                {{CustomerInfo.superior}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      客户编号
                </template>
                {{CustomerInfo.customerNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      客户状态
                 </template>
                 {{CustomerInfo.customerStatus}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      客户类型
                 </template>
                 {{CustomerInfo.customerType}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      销售负责人
                 </template>
                 {{CustomerInfo.staffFollower}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      重要级别
                 </template>
                 {{CustomerInfo.level}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      最新服务时间
                 </template>
                 {{CustomerInfo.contactDateLast}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      最新分配人
                 </template>
                 {{CustomerInfo.followLast}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      是否新客户
                </template>
                {{CustomerInfo.isNewCu}}
              </el-descriptions-item>
            </el-descriptions>
           </el-form>
           </el-collapse-item>

            <el-collapse-item title="工商信息" name="2">
            <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
              <el-descriptions class="margin-top"  :column="2" :size="size" border>
                    <el-descriptions-item >
                      <template slot="label">
                            纳税人识别号
                      </template>
                      {{CustomerInfo.taxpayerNo}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            注册时间
                      </template>
                      {{CustomerInfo.registerDate}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            公司性质
                      </template>
                      {{CustomerInfo.companyNature}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            客户规模
                      </template>
                      {{CustomerInfo.customerSize}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            法定代表人
                      </template>
                      {{CustomerInfo.legalRepresent}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            注册资金
                      </template>
                      {{CustomerInfo.registerAc}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            所属行业
                      </template>
                      {{CustomerInfo.industry}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            经营范围
                      </template>
                      {{CustomerInfo.businessScope}}
                    </el-descriptions-item>
              </el-descriptions>
           </el-form>
            </el-collapse-item>

            <el-collapse-item title="动态信息" name="3">
              <el-form ref="customerList" :model="customerList" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                下次回访日期
                          </template>
                            {{CustomerInfo.nextRevisitTime}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                未联系天数
                          </template>
                          177
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                最新联系日期
                          </template>
                          {{CustomerInfo.contactDateLast}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                最新进展
                          </template>
                          {{CustomerInfo.lastProgress}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                创建时间
                          </template>
                          {{CustomerInfo.createTime}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                修改时间
                          </template>
                          {{updateTime}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="首要联系人" name="4">
              <el-form ref="FirstContactInfo" :model="FirstContactInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人姓名
                          </template>
                          {{FirstContactInfo.telName}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人职务
                          </template>
                          {{FirstContactInfo.position}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人称谓
                          </template>
                          {{FirstContactInfo.conSex}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                办公电话
                          </template>
                          {{FirstContactInfo.officePhone}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人手机
                          </template>
                          {{FirstContactInfo.telephone}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人住址
                          </template>
                          {{FirstContactInfo.conAddress}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人Email
                          </template>
                          {{FirstContactInfo.conEmail}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="地址信息" name="5">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        国家
                                  </template>
                                  {{CustomerInfo.country}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        省份
                                  </template>
                                  {{CustomerInfo.province}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        城市
                                  </template>
                                  {{CustomerInfo.city}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        区域
                                  </template>
                                  {{CustomerInfo.region}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        详细地址
                                  </template>
                                  {{CustomerInfo.address}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                    </el-collapse-item>

                        <el-collapse-item title="备注信息" name="6">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        备注
                                  </template>
                                  {{CustomerInfo.markInfo}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

                     <el-collapse-item title="附件信息" name="7">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        附件信息
                                  </template>
                                  {{CustomerInfo.enclosureInfo}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

                     <el-collapse-item title="服务合同信息" name="8">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        合同服务信息
                                  </template>
                                  {{CustomerInfo.serviceContractInfo}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

                     <el-collapse-item title="评论信息" name="9">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        评论信息
                                  </template>
                                  {{CustomerInfo.comment}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

           </el-collapse>
          </el-tab-pane>

          <el-tab-pane label="联系人" name="10">
            <el-form ref="Contact" :model="Contact" :rules="rules" label-width="100px">
              <el-table :data="Contact" @selection-change="handleSelectionChange" empty-text="暂无数据">
                            <el-table-column label="联系人姓名" align="center" prop="telName" >
                                          <template slot-scope="scope">
                                            <el-button
                                              size="mini"
                                              type="text"
                                              @click="getContactInfo(scope.row)"
                                              v-hasPermi="['system:return:list']"
                                            >{{scope.row.telName}}</el-button>
                                          </template>
                            </el-table-column>
                <el-table-column label="联系人编号" align="center" prop="telNo" />
                <el-table-column label="职务" align="center" prop="position" />
                <el-table-column label="手机" align="center" prop="telephone" />
                <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                <el-table-column label="修改时间" align="center" prop="updateTime" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleUpdate(scope.row)"
                      v-hasPermi="['system:customer:edit']"
                    >修改</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="handleDelete(scope.row)"
                      v-hasPermi="['system:customer:remove']"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-tab-pane>

          <el-tab-pane label="跟进记录" name="11">
          <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                    <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                      <el-table-column label="主题" align="center" prop="theme"/>
                                                 <el-table-column label="联系人姓名" align="center" prop="telName" >
                                                                <template slot-scope="scope">
                                                                  <el-button
                                                                    size="mini"
                                                                    type="text"
                                                                    @click="getContactInfo(scope.row)"
                                                                    v-hasPermi="['system:quotation:list']"
                                                                  >{{scope.row.telName}}</el-button>
                                                                </template>
                                                  </el-table-column>
                      <el-table-column label="客户状态" align="center" prop="status" />
                      <el-table-column label="联系方式" align="center" prop="howContact" />
                      <el-table-column label="联系日期" align="center" prop="contactDate" />
                      <el-table-column label="负责人" align="center" prop="staffFollower" />
                      <el-table-column label="跟进记录" align="center" prop="followRecord" />
                      <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                    </el-table>
                  </el-form>
          </el-tab-pane>
    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="submitForm1">确 定</el-button>
           <el-button @click="cancel1">取 消</el-button>
         </div>
      </el-dialog>

  <el-dialog :title="title" :visible.sync="contactDialog" width="800px" append-to-body>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="联系人" name="conFirst">
            <el-collapse v-model="activeNames" @change="handleChange">
              <el-collapse-item title="联系人详情" name="con1">
                <el-form ref="ContactByTelName" :model="ContactByTelName" :rules="rules" label-width="80px">
                  <el-descriptions class="margin-top"  :column="2" :size="size" border>
                          <el-descriptions-item >
                            <template slot="label">
                                  联系人编号
                            </template>
                            {{ContactByTelName.telNo}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  联系人姓名
                            </template>
                            {{ContactByTelName.telName}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  联系人称谓
                            </template>
                            {{ContactByTelName.conSex}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  客户名称
                            </template>
                            {{ContactByTelName.customerName}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  联系人手机
                            </template>
                            {{ContactByTelName.telephone}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  联系人职务
                            </template>
                            {{ContactByTelName.position}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  销售负责人
                            </template>
                            {{ContactByTelName.staffFollower}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  办公电话
                            </template>
                            {{ContactByTelName.officePhone}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  Email
                            </template>
                            {{ContactByTelName.conEmail}}
                          </el-descriptions-item>
                          <el-descriptions-item >
                            <template slot="label">
                                  修改时间
                            </template>
                            {{ContactByTelName.updateTime}}
                          </el-descriptions-item>
                  </el-descriptions>
                </el-form>
              </el-collapse-item>

              <el-collapse-item title="地址信息" name="con2">
                <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            国家
                                      </template>
                                      {{CustomerInfo.country}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            省份
                                      </template>
                                      {{CustomerInfo.province}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            城市
                                      </template>
                                      {{CustomerInfo.city}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            区域
                                      </template>
                                      {{CustomerInfo.region}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            联系人地址
                                      </template>
                                      {{ContactByTelName.conAddress}}
                                    </el-descriptions-item>
                            </el-descriptions>
                </el-form>
              </el-collapse-item>
              </el-collapse>
          </el-tab-pane>
            <el-tab-pane label="跟进记录" name="conSecond">
            <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                      <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                        <el-table-column label="主题" align="center" prop="theme"/>
                                    <el-table-column label="客户名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                                            <template slot-scope="scope">
                                              <el-button
                                                size="mini"
                                                type="text"
                                                @click="getCustomerInfo1(scope.row)"
                                                v-hasPermi="['system:quotation:list']"
                                              >{{scope.row.customerName}}</el-button>
                                            </template>
                                    </el-table-column>
                        <el-table-column label="客户状态" align="center" prop="status" />
                        <el-table-column label="联系方式" align="center" prop="howContact" />
                        <el-table-column label="联系日期" align="center" prop="contactDate" />
                        <el-table-column label="负责人" align="center" prop="staffFollower" />
                        <el-table-column label="跟进记录" align="center" prop="followRecord" />
                        <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                      </el-table>
                    </el-form>
            </el-tab-pane>
      </el-tabs>
           <div slot="footer" class="dialog-footer">
             <el-button type="primary" @click="submitForm2">确 定</el-button>
             <el-button @click="cancel2">取 消</el-button>
           </div>
        </el-dialog>

<el-dialog :title="title" :visible.sync="productVisible" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="产品详情" name="proFirst">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="基本信息" name="p1">
           <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
              <el-descriptions-item >
                <template slot="label">
                      产品名称
                </template>
                {{ProductInfo.productName}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      产品编号
                </template>
                {{ProductInfo.productNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      编码或条形码
                </template>
                {{ProductInfo.encrypt}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      产品类别
                 </template>
                 {{ProductInfo.productType}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      规格型号
                 </template>
                 {{ProductInfo.productModel}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      计量单位
                 </template>
                 {{ProductInfo.measureUnit}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      禁用
                 </template>
                 {{ProductInfo.isDisable}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      创建人
                 </template>
                 {{ProductInfo.creator}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      创建时间
                 </template>
                 {{ProductInfo.createTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      修改时间
                </template>
                {{ProductInfo.updateTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      最新更新人
                </template>
                {{ProductInfo.updatePer}}
              </el-descriptions-item>
            </el-descriptions>
           </el-form>
           </el-collapse-item>

            <el-collapse-item title="价格信息" name="p2">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                产品报价（RMB）
                          </template>
                            {{ProductInfo.productOffer}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                参考成本价（RMB）
                          </template>
                          {{ProductInfo.costPrice}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="存库信息" name="p3">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                总库存量
                          </template>
                            {{ProductInfo.totalStock}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                安全库存
                          </template>
                          {{ProductInfo.safeStock}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                负责人
                          </template>
                          {{ProductInfo.follower}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="产品图片信息" name="p4">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                产品图片
                          </template>
                            {{ProductInfo.productPhoto}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="备注信息" name="p5">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                备注信息
                          </template>
                            {{ProductInfo.remarkInfo}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="评论信息" name="p6">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                评论信息
                          </template>
                            {{ProductInfo.comment}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>



           </el-collapse>
          </el-tab-pane>

          <el-tab-pane label="客户" name="p7">
            <el-form ref="CustomerInfoForProduct" :model="CustomerInfoForProduct" :rules="rules" label-width="80px">
                          <el-table :data="CustomerInfoForProduct" @selection-change="handleSelectionChange" empty-text="暂无数据">
                            <el-table-column label="客户名称" align="center" prop="customerName"/>
                            <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                            <el-table-column label="重要级别" align="center" prop="level" />
                            <el-table-column label="未联系天数" align="center"  />
                            <el-table-column label="客户类型" align="center" prop="customerType" />
                            <el-table-column label="下次回访日期" align="center" prop="nextRevisitTime" />
                            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                              <template slot-scope="scope">
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-edit"
                                  @click="handleUpdate(scope.row)"
                                  v-hasPermi="['system:customer:edit']"
                                >修改</el-button>
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-delete"
                                  @click="handleDelete(scope.row)"
                                  v-hasPermi="['system:customer:remove']"
                                >删除</el-button>
                              </template>
                            </el-table-column>
                          </el-table>
                       </el-form>
          </el-tab-pane>

          <el-tab-pane label="联系人" name="p8">
            <el-form ref="Contact" :model="Contact" :rules="rules" label-width="80px">
                          <el-table :data="Contact" @selection-change="handleSelectionChange" empty-text="暂无数据">
                                                       <el-table-column label="联系人姓名" align="center" prop="telName" >
                                                                      <template slot-scope="scope">
                                                                        <el-button
                                                                          size="mini"
                                                                          type="text"
                                                                          @click="getContactInfo(scope.row)"
                                                                          v-hasPermi="['system:quotation:list']"
                                                                        >{{scope.row.telName}}</el-button>
                                                                      </template>
                                                        </el-table-column>
                            <el-table-column label="客户名称" align="center" prop="customerName" />
                            <el-table-column label="联系人编号" align="center" prop="telNo" />
                            <el-table-column label="职务" align="center" prop="position" />
                            <el-table-column label="手机" align="center" prop="telephone" />
                            <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                            <el-table-column label="修改时间" align="center" prop="updateTime" />
                            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                              <template slot-scope="scope">
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-edit"
                                  @click="handleUpdate(scope.row)"
                                  v-hasPermi="['system:customer:edit']"
                                >修改</el-button>
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-delete"
                                  @click="handleDelete(scope.row)"
                                  v-hasPermi="['system:customer:remove']"
                                >删除</el-button>
                              </template>
                            </el-table-column>
                          </el-table>
                       </el-form>
          </el-tab-pane>

    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="productSubmit">确 定</el-button>
           <el-button @click="productCancel">取 消</el-button>
         </div>
      </el-dialog>

 <el-dialog :title="title" :visible.sync="SaleReturnVisible" width="800px" append-to-body>
         <el-tabs v-model="activeName" @tab-click="handleClick">
           <el-tab-pane label="详情" name="ContractInfoFirst">
           <el-collapse v-model="activeNames" @change="handleChange">
             <el-collapse-item title="基本信息" name="sale1">
            <el-form ref="SaleReturnInfo" :model="SaleReturnInfo" :rules="rules" label-width="80px">
             <el-descriptions class="margin-top"  :column="2" :size="size" border>
               <el-descriptions-item >
                 <template slot="label">
                       销售退货单编号
                 </template>
                 {{SaleReturnInfo.returnNo}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       合同订单
                   <el-button
                    size="mini"
                    type="text"
                    @click="getContractInfo1(SaleReturnInfo)"
                    v-hasPermi="['system:contract:list']"
                    >{{SaleReturnInfo.contractNo}}</el-button>
                 </template>
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       客户名称
                 </template>
                 {{SaleReturnInfo.customerName}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                      退入仓库
                  </template>
                  {{SaleReturnInfo.returnFac}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       销售负责人
                  </template>
                  {{SaleReturnInfo.follower}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       退货日期
                  </template>
                  {{SaleReturnInfo.returnDate}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       退货原因
                  </template>
                  {{SaleReturnInfo.reasonReturn}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       创建时间
                  </template>
                  {{SaleReturnInfo.createTime}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       创建人
                 </template>
                 {{SaleReturnInfo.creator}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       修改时间
                 </template>
                 {{SaleReturnInfo.updateTime}}
               </el-descriptions-item>
             </el-descriptions>
            </el-form>
            </el-collapse-item>

             <el-collapse-item title="动态信息" name="sale2">
               <el-form ref="SaleReturnInfo" :model="SaleReturnInfo" :rules="rules" label-width="80px">
                 <el-descriptions class="margin-top"  :column="2" :size="size" border>
                         <el-descriptions-item >
                           <template slot="label">
                                 状态
                           </template>
                             {{SaleReturnInfo.status}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 最新更新人
                           </template>
                             {{SaleReturnInfo.updatePer}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 已退款
                           </template>
                             {{SaleReturnInfo.yrefund}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 应退款
                           </template>
                             {{SaleReturnInfo.srefund}}
                         </el-descriptions-item>
                 </el-descriptions>
               </el-form>
             </el-collapse-item>

             <el-collapse-item title="产品" name="sale3">
                 <el-form ref="QuatationProductInfo" :model="QuatationProductInfo" :rules="rules" label-width="100px">
                     <el-table :data="QuatationProductInfo" @selection-change="handleSelectionChange" empty-text="暂无数据">
                       <el-table-column type="selection" width="55" align="center" />
                                   <el-table-column label="产品名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                                           <template slot-scope="scope">
                                             <el-button
                                               size="mini"
                                               type="text"
                                               @click="getProductInfo1(scope.row)"
                                               v-hasPermi="['system:quotation:list']"
                                             >{{scope.row.productName}}</el-button>
                                           </template>
                                   </el-table-column>
                       <el-table-column label="产品编号" align="center" prop="productNo" />
                       <el-table-column label="规格型号" align="center" prop="measureUnit" />
                       <el-table-column label="数量" align="center" prop="count" />
                       <el-table-column label="不含税单价" align="center" prop="unitPriceExTax" />
                       <el-table-column label="不含税金额" align="center" prop="accountExTax" />
                       <el-table-column label="折扣率" align="center" prop="discountRate" />
                       <el-table-column label="税额" align="center" prop="taxAmount" />
                       <el-table-column label="实际含税单价" align="center" prop="unitPrice" />
                       <el-table-column label="价税合计" align="center" prop="taxRevenue" />
                       <el-table-column label="描述" align="center" prop="description" />
                       <el-table-column label="增值税" align="center" prop="vat" />
                     </el-table>
                   </el-form>
               </el-form>
             </el-collapse-item>

             <el-collapse-item title="评论信息" name="sale4">
               <el-form ref="SaleReturnInfo" :model="SaleReturnInfo" :rules="rules" label-width="80px">
                 <el-descriptions class="margin-top"  :column="2" :size="size" border>
                         <el-descriptions-item >
                           <template slot="label">
                                 评论信息
                           </template>
                             {{SaleReturnInfo.comment}}
                         </el-descriptions-item>
                 </el-descriptions>
               </el-form>
             </el-collapse-item>


            </el-collapse>
           </el-tab-pane>

     </el-tabs>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="saleReturnSubmit">确 定</el-button>
            <el-button @click="saleReturnCancel">取 消</el-button>
          </div>
       </el-dialog>

<el-dialog :title="title" :visible.sync="ContractInfoVisible" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="详情" name="ContractInfoFirst">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="基本信息" name="c1">
           <el-form ref="ContractInfo" :model="ContractInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
              <el-descriptions-item >
                <template slot="label">
                      合同编号
                </template>
                {{ContractInfo.contractNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      客户名称
                </template>
                {{ContractInfo.customerName}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      销售机会
                </template>
                {{ContractInfo.oppoName}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      选择源单
                 </template>
                 {{ContractInfo.documentNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      签约日期
                 </template>
                 {{ContractInfo.contractDate}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      订单状态
                 </template>
                 {{ContractInfo.status}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      销售负责人
                 </template>
                 {{ContractInfo.staffFollower}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      交付日期
                 </template>
                 {{ContractInfo.deliverDate}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      创建人
                 </template>
                 {{ContractInfo.creator}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      物流公司
                </template>
                {{ContractInfo.logisticsCompany}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      物流单号
                </template>
                {{ContractInfo.logisticsOrder}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      数量合计
                </template>
                {{ContractInfo.amount}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      修改时间
                </template>
                {{ContractInfo.updateTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      审批状态
                </template>
                {{ContractInfo.approvalStatus}}
              </el-descriptions-item>
            </el-descriptions>
           </el-form>
           </el-collapse-item>

            <el-collapse-item title="条款与条件" name="c2">
              <el-form ref="ContractInfo" :model="ContractInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                条款与条件
                          </template>
                            {{ContractInfo.condition}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="产品" name="c3">
                <el-form ref="QuatationProductInfo" :model="QuatationProductInfo" :rules="rules" label-width="100px">
                    <el-table :data="QuatationProductInfo" @selection-change="handleSelectionChange" empty-text="暂无数据">
                      <el-table-column type="selection" width="55" align="center" />
                                  <el-table-column label="产品名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                                          <template slot-scope="scope">
                                            <el-button
                                              size="mini"
                                              type="text"
                                              @click="getProductInfo1(scope.row)"
                                              v-hasPermi="['system:quotation:list']"
                                            >{{scope.row.productName}}</el-button>
                                          </template>
                                  </el-table-column>
                      <el-table-column label="产品编号" align="center" prop="productNo" />
                      <el-table-column label="规格型号" align="center" prop="measureUnit" />
                      <el-table-column label="数量" align="center" prop="count" />
                      <el-table-column label="不含税单价" align="center" prop="unitPriceExTax" />
                      <el-table-column label="不含税金额" align="center" prop="accountExTax" />
                      <el-table-column label="折扣率" align="center" prop="discountRate" />
                      <el-table-column label="税额" align="center" prop="taxAmount" />
                      <el-table-column label="实际含税单价" align="center" prop="unitPrice" />
                      <el-table-column label="价税合计" align="center" prop="taxRevenue" />
                      <el-table-column label="描述" align="center" prop="description" />
                      <el-table-column label="增值税" align="center" prop="vat" />
                    </el-table>
                  </el-form>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="评论信息" name="c4">
              <el-form ref="ContractInfo" :model="ContractInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                评论信息
                          </template>
                            {{ContractInfo.comment}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>


           </el-collapse>
          </el-tab-pane>

    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="contractSubmit">确 定</el-button>
           <el-button @click="contractCancel">取 消</el-button>
         </div>
      </el-dialog>

<el-dialog :title="title" :visible.sync="RefundVisible" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="详情" name="ContractInfoFirst">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="基本信息" name="R1">
           <el-form ref="RefundInfo" :model="RefundInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
              <el-descriptions-item >
                <template slot="label">
                      客户名称
                </template>
                {{RefundInfo.customerName}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      退款单编号
                </template>
                {{RefundInfo.refundNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      退货单
                </template>
                {{RefundInfo.returnNo}}                                                                                                                                                                                                                                 fo.oppoName}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      销售负责人
                 </template>
                 {{RefundInfo.follower}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      退款日期
                 </template>
                 {{RefundInfo.refundDate}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      付款方式
                 </template>
                 {{RefundInfo.payType}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      账户
                 </template>
                 {{RefundInfo.account}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      是否开票
                 </template>
                 {{RefundInfo.isInvoice}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      合计
                 </template>
                 {{RefundInfo.total}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      修改时间
                </template>
                {{RefundInfo.updateTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      创建时间
                </template>
                {{RefundInfo.createTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      创建人
                </template>
                {{RefundInfo.creator}}
              </el-descriptions-item>
            </el-descriptions>
           </el-form>
           </el-collapse-item>

            <el-collapse-item title="备注信息" name="R2">
              <el-form ref="RefundInfo" :model="RefundInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                备注
                          </template>
                            {{RefundInfo.markInfo}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="产品" name="R3">
                <el-form ref="QuatationProductInfo" :model="QuatationProductInfo" :rules="rules" label-width="100px">
                    <el-table :data="QuatationProductInfo" @selection-change="handleSelectionChange" empty-text="暂无数据">
                      <el-table-column type="selection" width="55" align="center" />
                                  <el-table-column label="产品名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                                          <template slot-scope="scope">
                                            <el-button
                                              size="mini"
                                              type="text"
                                              @click="getProductInfo1(scope.row)"
                                              v-hasPermi="['system:quotation:list']"
                                            >{{scope.row.productName}}</el-button>
                                          </template>
                                  </el-table-column>
                      <el-table-column label="产品编号" align="center" prop="productNo" />
                      <el-table-column label="规格型号" align="center" prop="measureUnit" />
                      <el-table-column label="数量" align="center" prop="count" />
                      <el-table-column label="不含税单价" align="center" prop="unitPriceExTax" />
                      <el-table-column label="不含税金额" align="center" prop="accountExTax" />
                      <el-table-column label="折扣率" align="center" prop="discountRate" />
                      <el-table-column label="税额" align="center" prop="taxAmount" />
                      <el-table-column label="实际含税单价" align="center" prop="unitPrice" />
                      <el-table-column label="价税合计" align="center" prop="taxRevenue" />
                      <el-table-column label="描述" align="center" prop="description" />
                      <el-table-column label="增值税" align="center" prop="vat" />
                    </el-table>
                  </el-form>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="评论信息" name="R4">
              <el-form ref="RefundInfo" :model="RefundInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                评论信息
                          </template>
                            {{RefundInfo.comment}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>


           </el-collapse>
          </el-tab-pane>

    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="refundSubmit">确 定</el-button>
           <el-button @click="refundCancel">取 消</el-button>
         </div>
      </el-dialog>


    <!-- 添加或修改销售退款单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="销售退款单编号" prop="refundNo">
          <el-input v-model="form.refundNo" placeholder="请输入销售退款单编号" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="退货单" prop="returnNo">
          <el-input v-model="form.returnNo" placeholder="请输入退货单" />
        </el-form-item>
        <el-form-item label="退款日期" prop="refundDate">
          <el-date-picker clearable size="small"
            v-model="form.refundDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择退款日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="账户" prop="account">
          <el-input v-model="form.account" placeholder="请输入账户" />
        </el-form-item>
        <el-form-item label="是否开票" prop="isInvoice">
          <el-input v-model="form.isInvoice" placeholder="请输入是否开票" />
        </el-form-item>
        <el-form-item label="付款方式" prop="payType">
          <el-select v-model="form.payType" placeholder="请选择付款方式">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="销售负责人" prop="follower">
          <el-input v-model="form.follower" placeholder="请输入销售负责人" />
        </el-form-item>
        <el-divider content-position="center">顾客产品信息信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddCustomerProduct">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteCustomerProduct">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="customerProductList" :row-class-name="rowCustomerProductIndex" @selection-change="handleCustomerProductSelectionChange" ref="customerProduct">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
           <el-table-column label="产品名称" prop="productName">
            <template slot-scope="scope">
                            <el-button
                              size="mini"
                              type="text"
                              @click="getProductInfo1(scope.row)"
                              v-hasPermi="['system:quotation:list']"
                            >{{scope.row.productName}}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="产品名称(更改后)" prop="productName">
            <template slot-scope="scope">
                            <el-button
                              size="mini"
                              type="text"
                              @click="getProductInfoChange(scope.row)"
                              v-hasPermi="['system:quotation:list']"
                            >{{scope.row.productNameChange}}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="quantity">
            <template slot-scope="scope">
              <el-input v-model="scope.row.quantity" placeholder="请输入数量" />
            </template>
          </el-table-column>
          <el-table-column label="价税合计" prop="taxRevenue">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxRevenue" placeholder="请输入价税合计" />
            </template>
          </el-table-column>
          <el-table-column label="未出库数量" prop="uncheckoutNum">
            <template slot-scope="scope">
              <el-input v-model="scope.row.uncheckoutNum" placeholder="请输入未出库数量" />
            </template>
          </el-table-column>
          <el-table-column label="已出库数量" prop="checkoutNum">
            <template slot-scope="scope">
              <el-input v-model="scope.row.checkoutNum" placeholder="请输入已出库数量" />
            </template>
          </el-table-column>
          <el-table-column label="服务开始日" prop="serviceBdate">
            <template slot-scope="scope">
              <el-input v-model="scope.row.serviceBdate" placeholder="请输入服务开始日" />
            </template>
          </el-table-column>
          <el-table-column label="服务到期日" prop="serviceEdate">
            <template slot-scope="scope">
              <el-input v-model="scope.row.serviceEdate" placeholder="请输入服务到期日" />
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRefund, getRefund, delRefund, addRefund, updateRefund,getCustomerInfo,getFollowRecord,getContact,getContactByTelName,getFirstContactInfoByCustomerName,getProductInfoByName ,getContractByNo,getQuatationProductInfoByName,getInfoByReturnNo,getInfoByRefundNo } from "@/api/crm/sale/refund";

export default {
  name: "Refund",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedCustomerProduct: [],
      activeNames: ['1'],
      activeName: 'second',
      CustomerInfo: {},
      FollowRecord: [],
      ContactByTelName: {},
      Contact: [],
      ContactObj: {},
      FirstContactInfo: {},
      dialogVisible: false,
      contactDialog: false,
      ProductInfo: {},
      productVisible: false,
      ContractInfoVisible: false,
      SaleReturnVisible: false,
      ContractInfo: {},
      QuatationProductInfo: [],
      SaleReturnInfo: {},
      RefundVisible: false,
      RefundInfo: {},
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 销售退款单表格数据
      refundList: [],
      // 顾客产品信息表格数据
      customerProductList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        refundNo: null,
        customerName: null,
        returnNo: null,
        refundDate: null,
        account: null,
        isInvoice: null,
        payType: null,
        follower: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询销售退款单列表 */
    getList() {
      this.loading = true;
      listRefund(this.queryParams).then(response => {
        this.refundList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
                         cancel1() {
                                       this.dialogVisible = false;
                                       this.Contact=[];
                                       this.reset();
                                     },
                        cancel2() {
                          this.contactDialog = false;
                          this.reset();
                        },
                        productCancel(){
                          this.productVisible=false;
                          this.Contact=[];
                          this.CustomerInfoForProduct=[];
                        },
                        contractCancel(){
                          this.ContractInfoVisible=false;
                          this.reset();
                        },
                                     saleReturnCancel(){
                                        this.SaleReturnVisible=false;
                                     },
                                     refundCancel(){
                                        this.RefundVisible= false;
                                     },
                                     submitForm1() {
                                       this.dialogVisible = false;
                                       this.Contact=[];
                                       this.reset();
                                     },
                                                submitForm2() {
                                                  this.contactDialog = false;
                                                  this.reset();
                                                },
                                                 productSubmit(){
                                                   this.productVisible=false;
                                                   this.Contact=[];
                                                   this.CustomerInfoForProduct=[];
                                                 },
                                                 contractSubmit(){
                                                   this.ContractInfoVisible=false;
                                                 },
                                                saleReturnSubmit(){
                                                   this.SaleReturnVisible=false;
                                                   this.reset();
                                                },
                                                refundSubmit(){
                                                  this.RefundVisible = false;
                                                },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        refundNo: null,
        customerName: null,
        returnNo: null,
        refundDate: null,
        account: null,
        isInvoice: null,
        payType: null,
        follower: null,
        updateTime: null
      };
      this.customerProductList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加销售退款单";
    },

getCustomerInfo1(row){
      const customerName = row.customerName;
      const telName=row.telName;
      this.updateTime= row.updateTime;
      this.uncontactDays=row.uncontactDays;
      getCustomerInfo(customerName).then(response => {
          this.CustomerInfo=response.data;
          console.log(this.CustomerInfo)
          this.dialogVisible=true;
          this.title= "客户信息";
          this.size='50';
      })
      getFollowRecord(customerName).then(response => {
                          let list=response.data;
                          this.FollowRecord=response.data;
                          this.dialogVisible=true;
                          this.size='50';
      })
      getContact(customerName).then(response => {
                          this.ContactObj=response.data;
                          let list =response.data;
                          this.Contact.push(...response.data);
                          this.dialogVisible=true;
                          this.size='50';
      })
      getFirstContactInfoByCustomerName(customerName).then(response => {
          this.FirstContactInfo=response.data;
                          this.dialogVisible=true;
                          this.size='50';
      })
    },

 getContactInfo(row){
    this.contactDialog=true;
    const telName = row.telName;
                        const customerName = row.customerName;
                        this.updateTime= row.updateTime;
                        this.uncontactDays=row.uncontactDays;
              getContactByTelName(telName).then(response => {
                   this.ContactByTelName=response.data;
                   console.log(this.ContactByTelName)
                   this.size='50';
              })
                    getCustomerInfo(customerName).then(response => {
                        this.CustomerInfo=response.data;
                        console.log(this.CustomerInfo);
                        this.size='50';
                    })
                         getFollowRecord(customerName).then(response => {
                                             let list=response.data;
                                             this.FollowRecord=response.data;
                                             this.size='50';
                         })
    },
getProductInfo1(row){
      this.productVisible=true;
      const productName=row.productName;
      const customerName=row.customerName;
      getProductInfoByName(productName).then(response =>{
        this.ProductInfo=response.data;
        this.size='50';
        this.title = "产品信息"
      })
                          getCustomerInfo(customerName).then(response => {
                              const data=response.data;
                              this.CustomerInfoForProduct.push(response.data);
                              console.log(response.data);
                              this.size='50';
                          })
                                getContact(customerName).then(response => {
                                                    this.ContactObj=response.data;
                                                    let list =response.data;
                                                    this.Contact.push(...response.data);
                                                    this.size='50';
                                })
    },

getProductInfoChange(row){
      this.productVisible=true;
      const productName=row.productNameChange;
      const customerName=row.customerName;
      getProductInfoByName(productName).then(response =>{
        this.ProductInfo=response.data;
        this.size='50';
        this.title = "产品信息"
      })
                          getCustomerInfo(customerName).then(response => {
                              const data=response.data;
                              this.CustomerInfoForProduct.push(response.data);
                              console.log(response.data);
                              this.size='50';
                          })
                                getContact(customerName).then(response => {
                                                    this.ContactObj=response.data;
                                                    let list =response.data;
                                                    this.Contact.push(...response.data);
                                                    this.size='50';
                                })
    },

    getInfoByReturnNo1(row){
      this.SaleReturnVisible=true;
      const returnNo=row.returnNo;
      const customerName=row.customerName;
      getInfoByReturnNo(returnNo).then(response=>{
        this.SaleReturnInfo=response.data;
      })
            getQuatationProductInfoByName(customerName).then(response=>{
                  this.QuatationProductInfo=response.data;
                  console.log(this.QuatationProductInfo)
            })
    },

    getContractInfo1(row){
        this.ContractInfoVisible=true;
        const contractNo=row.contractNo;
        const customerName=row.customerName;
        getContractByNo(contractNo).then(response => {
          this.ContractInfo=response.data;
          console.log(response.data)
          this.size='50';
        })
            getQuatationProductInfoByName(customerName).then(response=>{
                  this.QuatationProductInfo=response.data;
                  console.log(this.QuatationProductInfo)
            })
    },
getRefundInfo(row){
  this.RefundVisible=true;
  const refundNo=row.refundNo;
  const customerName=row.customerName;
  getInfoByRefundNo(refundNo).then(response=>{
      this.RefundInfo=response.data;
  })
            getQuatationProductInfoByName(customerName).then(response=>{
                  this.QuatationProductInfo=response.data;
                  console.log(this.QuatationProductInfo)
            })
},
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRefund(id).then(response => {
        this.form = response.data;
        this.customerProductList = response.data.customerProductList;
        this.open = true;
        this.title = "修改销售退款单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.customerProductList = this.customerProductList;
          if (this.form.id != null) {
            updateRefund(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRefund(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除销售退款单编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delRefund(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
	/** 顾客产品信息序号 */
    rowCustomerProductIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 顾客产品信息添加按钮操作 */
    handleAddCustomerProduct() {
      let obj = {};
      obj.productName = "";
      obj.productNameChange = "";
      obj.quantity = "";
      obj.taxRevenue = "";
      obj.uncheckoutNum = "";
      obj.checkoutNum = "";
      obj.serviceBdate = "";
      obj.serviceEdate = "";
      this.customerProductList.push(obj);
    },
    /** 顾客产品信息删除按钮操作 */
    handleDeleteCustomerProduct() {
      if (this.checkedCustomerProduct.length == 0) {
        this.$alert("请先选择要删除的顾客产品信息数据", "提示", { confirmButtonText: "确定", });
      } else {
        this.customerProductList.splice(this.checkedCustomerProduct[0].index - 1, 1);
      }
    },
    /** 单选框选中数据 */
    handleCustomerProductSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.customerProduct.clearSelection();
        this.$refs.customerProduct.toggleRowSelection(selection.pop());
      } else {
        this.checkedCustomerProduct = selection;
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('crm/refund/export', {
        ...this.queryParams
      }, `crm_refund.xlsx`)
    }
  }
};
</script>
